package com.ccb.sc.conf;

import com.ccb.sc.auth.TokenAuthInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ken
 * @version 1.0
 * @date 2020-09-14
 */
@Configuration
public class WebAppMvcConfig implements WebMvcConfigurer {

    @Bean
    public TokenAuthInterceptor tokenAuthInterceptor(){
        return new TokenAuthInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(tokenAuthInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns("/payment/notify/*", "/v3/api-docs", "/docs", "/swagger-ui/**");
    }

}
